const obj = {
  name: "frank",
  age: 18,
  friends: {
    name: "kobe",
  },
  hobbies: ["篮球", "足球"],
  foo: function () {
    console.log("foo function");
  },
};

// 将obj对象的内容放到info变量中
// 1. 引用赋值
const info = obj;
obj.age = 100;
console.log(info.age);

// 2. 深拷贝
const info2 = { ...obj };
obj.age = 1000;
console.log(info2.age);

obj.friends.name = "why";
console.log(info2.friends.name);

// 3. 利用JSON序列化做深拷贝
const info3 = JSON.stringify(obj);
console.log(JSON.parse(info3));
